﻿using Inovout.Organizations.Models;
using Inovout.Organizations.Services;
using Inovout.Web.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Inovout.Kuajing.Exports.Console.Web.Controllers
{

    public class OrganizationUnitController : KJBaseController<OrganizationUnit>
    {
        private IOrganizationUnitService organizationUnitService;

        public OrganizationUnitController(IOrganizationUnitService organizationUnitService)
        {
            this.organizationUnitService = organizationUnitService;
        }


        [HttpPost]
        public JsonResult FilterOrganiziation(string term)
        {
            List<OrganizationUnit> organizationUnitList = (List<OrganizationUnit>)organizationUnitService.FindByKey(term);
            var data = from c in organizationUnitList
                       select new { value = c.Id, label = c.Name,location=c.Location.Id };

            return Json(data, JsonRequestBehavior.AllowGet);
        }

	}
}